import request from '@/utils/request.js'

/**
 * 获取新闻文章详情
 * @param {*} id 文章id
 * @returns
 */
export function getArticleDetail (id) {
  return request({
    url: '/v1_0/articles/' + id
  })
}

/**
 * 关注用户
 * @param {*} target 关注目标（被关注的用户id）
 * @returns
 */
export function followUser (target) {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}

/**
 * 取消关注用户
 * @param {*} target 目标用户（被取消关注的用户id）
 * @returns
 */
export function deleteUser (target) {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}

/**
 * 收藏文章
 * @param {*} target 收藏的目标文章id
 * @returns
 */
export function addCollect (target) {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}
// 🙁☹️☹️☹️☹️☹️☹️☹️
/**
 * 取消收藏文章
 * @param {*} target 目标文章id
 * @returns
 */
export function deleteCollect (target) {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/collections/' + target
  })
}

/**
 * 获取评论或评论回复
 * @param {Object} params
 * @returns
 */
export function getComment (params) {
  return request({
    url: '/v1_0/comments',
    params
  })
}

/**
 * 添加评论或评论回复
 * @param {Object} data {target,content,art_id}
 * @returns
 */
export function sendComment (data) {
  return request({
    url: '/v1_0/comments',
    method: 'post',
    data
  })
}
